import { defineStore } from 'pinia'
import { getWeatherApi } from '@/apis/index'

export const useWeatherStore = defineStore(
  'weather',
  () => {
    const weatherInfo = ref({})

    const getWeatherInfo = async (params) => {
      const result = await getWeatherApi(params)
      weatherInfo.value = result.dt.lives[0]
    }

    return {
      weatherInfo,
      getWeatherInfo,
    }
  },
  {
    persist: true,
  },
)
